#pragma once

#include <thread>
#include <atomic>
#include <string>
#include <memory>

class Input;
typedef std::shared_ptr<Input> InputPtr;

class Input
{
public:
    static InputPtr getSingleton();
	Input();
	~Input();

    void init();

	void Main();
	void Join();

	std::atomic_bool &isReadReady() { return ready; }
	const std::string &getLine();

    std::atomic_bool &isBlocked() { return block; }
    void block_input() { block = true; }
    void unblock_input() { block = false; }

protected:
    static InputPtr singleton;
	std::thread thread;
	std::atomic_bool join;
	std::atomic_bool ready;
    std::atomic_bool block;
	std::string line;
	std::string output;
	std::string empty_line;
};
